
#include <iostream>
#include <string.h>
#include <unistd.h>

using namespace std;

class Father{
private:
	int money;

protected:
	int roomkey;
	
public:
	int address;
	void it_skill(void)
	{
		cout << "father's it_skill" <<endl;
	}
	
	int  getMoney(void){
		return money;
	}

	void  setMoney(int money){
		this->money = money;
	}
};

class Son_pub : public Father {
private:
	int toy;
	
public:
	void play_game(void)
	{
		int m;
		cout << "son play game" <<endl;
		m = getMoney();
		m--;
		setMoney(m);

		roomkey = 1;
	}
};

class Son_pro : protected Father {
private:
	int toy;
	
public:
	void play_game(void)
	{
		int m;
		cout << "son play game" <<endl;
		m = getMoney();
		m--;
		setMoney(m);

		roomkey = 1;
	}
};

class Son_pri : private Father {
private:
	int toy;
	
public:
	void play_game(void)
	{
		int m;
		cout << "son play game" <<endl;
		m = getMoney();
		m--;
		setMoney(m);

		roomkey = 1;
	}
};

class Grandson_pub : public Son_pub {

public:
	void test(void)
	{
		roomkey = 1;
		address = 2;
	}
};

class Grandson_pro : public Son_pro {

public:
	void test(void)
	{
		roomkey = 1;
		address = 2;
	}
};

class Grandson_pri : public Son_pri {

public:
	void test(void)
	{
		//roomkey = 1;  //failed
		//address = 2; //failed
	}
};



int main(int argc , char **argv)
{	
	
	Son_pub s_pub;
	Son_pro s_pro;
	Son_pri s_pri;
	
	s_pub.it_skill();
	//s_pro.it_skill();
	//s_pri.it_skill();

	Grandson_pub gs_pub;
	Grandson_pro gs_pro;
	Grandson_pri gs_pri;

	gs_pub.address =3;
	gs_pro.address =3;
	
	return 0;
}





